package game.views;

import game.data.ActionData;
import hx.display.Box;

/**
 * 技能描述项
 */
@:build(hx.macro.UIBuilder.build("assets/views/SkillDescItem.xml"))
class SkillDescItem extends Box {
	public function new(data:ActionData) {
		super();
        this.height = 220;
		this.nameLabel.data = data.name;
		var typeName = switch data.type {
			case AUTO:
				"[被动技能]";
			case GROUND_SKILL:
				"[陆面技能]";
			case AIR_SKILL:
				"[空中技能]";
			case ALL_SKILL:
				"[通用可用]";
			default:
				"[无]";
		};
		var content = typeName + ' CD：${data.cd}秒';
		if (data.mpConsume > 0) {
			content += ' 耗蓝：${data.mpConsume}';
		}
		if (data.diabledForce) {
			content += ' 禁用强制';
		}
		if (data.diabledForceFirst) {
			content += ' 禁用前置强制';
		}
		this.contentLabel.data = content;
		var cd:CDDisplay = new CDDisplay();
		cd.data = {
			groupKeys: data.groupKeys.copy(),
			maxCd: data.cd,
			data: null
		};
		this.addChild(cd);
		cd.scale = 0.4;
		cd.x = this.nameLabel.getTextWidth() + 60;
		cd.y = 25;
	}
}
